package cn.edu.stu.syllabus.repository.oaFile.remote;

import java.util.List;

import cn.edu.stu.syllabus.api.OaFileApi;
import cn.edu.stu.syllabus.repository.oaFile.OaFileConverter;
import cn.edu.stu.syllabus.repository.oaFile.OaFileDataSource;
import cn.edu.stu.syllabus.repository.oaFile.local.OaFileEntry;
import rx.Observable;
import rx.functions.Func1;

/**
 * Created by daidaijie on 2017/3/23.
 */

public class OaFileRemoteDataSource implements OaFileDataSource {

    OaFileApi mOaFileApi;

    public OaFileRemoteDataSource(OaFileApi oaFileApi) {
        mOaFileApi = oaFileApi;
    }

    @Override
    public Observable<List<OaFileEntry>> getOaFileEntry(long docId) {
        return mOaFileApi.getOAFileList("undefined", docId)
                .map(new Func1<List<OaFile>, List<OaFileEntry>>() {
                    @Override
                    public List<OaFileEntry> call(List<OaFile> oaFiles) {
                        return OaFileConverter.convert(oaFiles);
                    }
                });
    }
}
